package com.guangyunl.d_if;

import java.util.Random;

// 任意给出一个整数，请用程序实现判断是奇数还是偶数，并在控制台输出该整数是奇数还是偶数
public class Demo02If {
    public static void main(String[] args) {
        // 创建对象
        Random rd = new Random();
        int data1 = rd.nextInt();
        int result = data1 % 2;
        System.out.println("data1 = " + data1);
        System.out.println("result = " + result);
        if (result == 1 || result == -1){
            System.out.println("该整数为 " + data1 + " 是奇数");
        }
        if (result == 0){
            System.out.println("该整数为 " + data1 + " 是偶数");
        }

    }
}
